Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Extending the sample procedure with a dynamic browse
If you start with
h-CustOrderWin7.w, you can add a dynamic browse to it to illustrate some of the capabilities of this object.
![]()
To show all the OrderLines for the current Order in a browse:
- In the Definitions section, add these definitions:
The
hBrowsevariable will hold the handle of the dynamic browse you create, andhCalcColwill hold the handle of a dynamic calculated column for it. The query definition will be attached to the browse when you create it. These definitions need to be here at the top level of the procedure so that their values persist beyond the end of the trigger where they are assigned.- Add this statement to the end of the
initSelectioninternal procedure, which sets the list of OrderLine fields in the selection list:
The new entry represents a calculated column that holds the OrderLine price before the discount is applied.
- In the
LEAVEtrigger for the selection list called OlineFields, comment out all of the code.This code created dynamic fields to display an OrderLine. Now you’ll display a browse in the same place.
- Because you can create a browse over and over again with different lists of columns, you should first check to see if there’s already a dynamic browse and delete it:
- Add new code to create a dynamic browse. This complex statement defines the browse and its attributes:
- If necessary, adjust the size and position of the browse according to the layout of your own window and Order browse.
- Add code that walks through the selected fields from the OlineFields selection list as the dynamic fill-in code does:
- If the selected field is the calculated field, you must add a calculated column to the browse to display it:
- Otherwise, add a column like the selected field in the OrderLine table:
- Add this
ROW-DISPLAYtrigger, which executes each time a row is displayed in the browse:
Because the code in the trigger block for
LEAVEof OlineFields goes out of scope as soon as the trigger block ends, you must put the code for this nested trigger definition in a separate procedure, and use the special syntaxPERSISTENT RUN calcPriceB4Discto make Progress keep track of what to run when theROW-DISPLAYevent fires.- Add this
LEAVEtrigger to open the OrderLine query from the Definitions section:
You attached this query to the browse in the
CREATE BROWSEstatement.- Add this code for the
calcPriceB4Discprocedure:
A trigger such as this should always check first that its column handle is valid in case it is fired once before the column is created. In this case, the column is optional, so it must always check first to see if it’s there.
- In the
VALUE-CHANGEDtrigger for the OrderBrowse, comment out the existing code that blanks out the dynamic fill-ins and replace it with a statement that re-opens the OrderLine query:
This code refreshes the OrderLine browse each time an Order is selected.
- Add this statement to each of the four navigation button triggers to apply the Order browse’s
VALUE-CHANGEDtrigger:
The query opens when a new Customer is selected and its Orders first displayed.
- Run
h-CustOrderWin7.w. You can select some OrderLine fields along with the calculated field and see the results of your work:
![]()
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |